package com.it.system.course_service.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CourseMQConfig {

    public static final String QUEUE_UPDATE = "course-update-queue";
    public static final String QUEUE_DELETE = "course-delete-queue";
    public static final String EXCHANGE = "course-exchange";
    public static final String KEY_UPDATE = "course-update-key";
    public static final String KEY_DELETE = "course-delete-key";

    @Bean
    public TopicExchange courseExchange() {
        return new TopicExchange(EXCHANGE, true, false);
    }

    @Bean
    public Queue courseUpdateQueue() {
        return new Queue(QUEUE_UPDATE, true);
    }

    @Bean
    public Queue courseDeleteQueue() {
        return new Queue(QUEUE_DELETE, true);
    }

    @Bean
    public Binding courseUpdateBinding() {
        return BindingBuilder.bind(courseUpdateQueue())
                .to(courseExchange())
                .with(KEY_UPDATE);
    }

    @Bean
    public Binding courseDeleteBinding() {
        return BindingBuilder.bind(courseDeleteQueue())
                .to(courseExchange())
                .with(KEY_DELETE);
    }
}